package com.xt.wikiperfumapi.model.wrapper;

import com.xt.wikiperfumapi.model.PerfumeCommentInfo;
import com.xt.wikiperfumapi.model.vo.PerfumeCommentInfoVo;
import com.xt.wikiperfumapi.service.impl.UserInfoServiceImpl;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;

@Slf4j
public class PerfumeCommentWrapper {

    @Resource
    UserInfoServiceImpl userInfoService;

    public PerfumeCommentInfoVo perfumeCommentInfoToVo(PerfumeCommentInfo info){
        PerfumeCommentInfoVo perfumeCommentInfoVo=new PerfumeCommentInfoVo();
        try {
            BeanUtils.copyProperties(perfumeCommentInfoVo,info);
        }catch (Exception e){
            log.info(e.getMessage());
        }
        perfumeCommentInfoVo.setUserInfo(userInfoService.getById(info.getUserId()));
        return perfumeCommentInfoVo;
    }

}
